﻿using HPIT_Library;
using HPIT_Library_Modal;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace HPIT_Library_DAL
{
    public class AreaDAL
    {
        public static List<Area> AreaSelect(string parentID)
        {
            string sql = "select * from Area where parentID=@ParentID";
            SqlParameter[] pams = {
            new SqlParameter("@ParentID",parentID),
            };
            SqlDataReader reader = DbHelper.ExecuteReader(sql, pams);
            List<Area> list = new List<Area>();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Area area = new Area()
                    {
                        CodeID = reader["CodeID"].ToString(),
                        Name = reader["Name"].ToString(),
                        ParentID = reader["ParentID"].ToString(),

                    };
                    list.Add(area);

                }
                reader.Close();
            }
            return list;

        }
    }
}
